package com.mce.nebula.enums;

/**
 * 升级状态枚举
 */
public enum UpgradeStatus {
    NOT(1, "未升级"),
    UPGRADING(2, "升级中"),
    UPGRADED(3, "已升级"),
    ROLLING(4, "回滚中"),
    ROLLBACK(5, "已回滚"),
    PARTIAL_UPGRADED(6, "部分升级"),
    PARTIAL_ROLLBACK(7, "部分回滚"),
    UPGRADE_FAILED(8, "升级失败"),
    ROLLBACK_FAILED(9, "回滚失败"),
    DEPLOY_FAILED(10, "部署失败");

    private final int value;
    private final String description;

    UpgradeStatus(int value, String description) {
        this.value = value;
        this.description = description;
    }

    public int getValue() {
        return value;
    }

    public String getDescription() {
        return description;
    }

    public static UpgradeStatus fromValue(int value) {
        for (UpgradeStatus status : UpgradeStatus.values()) {
            if (status.getValue() == value) {
                return status;
            }
        }
        throw new IllegalArgumentException("Invalid UpgradeStatus value: " + value);
    }
}